﻿using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;

namespace S2_Xxxx_XxxNetApi.Controllers
{
    [Route("Xxxapi/[controller]/[action]")]
    public class UserController : ControllerBase
    {
        private AppSettings mySettings { get; set; }
        private IHostingEnvironment _hostingEnvironment;


        public UserController(IOptions<AppSettings> mySettings, IHostingEnvironment hostingEnvironment)
        {
            this.mySettings = mySettings.Value;
            _hostingEnvironment = hostingEnvironment;
        }


        [HttpGet]
        public dynamic TestSession(string UserId)
        {

            SessionHelper.SetString(this, "UserId", UserId);
            return new { userId = UserId, Msg = "调用成功" };
        }

        [HttpGet]
        public dynamic GetSession(string Key)
        {
            return SessionHelper.GetString(this, Key);
        }

        [HttpGet]
        public dynamic TestCookie(string UserId)
        {

            CookieHelper.SetCookie(this, "UserId", UserId,5);
            return new { userId = UserId, Msg = "调用成功" };
        }

        [HttpGet]
        public dynamic GetCookie(string Key)
        {
            return CookieHelper.GetCookie(this, Key);
        }

    }
}